package com.example.demo.controller;

import com.example.demo.common.Result;
import com.example.demo.dto.UserLoginDTO;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 登录相关
 */
@RestController
@RequestMapping("api/v1/users")
public class AuthController {
    @Autowired
    UserService userService;

    @PostMapping("/login")
    public Result login(@RequestBody UserLoginDTO userLoginDTO) {
        return userService.doLogin(userLoginDTO);
    }

    @GetMapping("/info")
    public Result info(@RequestHeader("Authorization")String token) {
//        System.out.println("token:"+token);
        return userService.getUserInfo(token);
    }
}
